package com.wushijia.repository;

import com.wushijia.model.User;
import javax.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;


public interface UserRepository extends CrudRepository<User, Integer>, JpaSpecificationExecutor<User> {

  @Query("select u from User u where u.username = ?1")
  User getUserByName(String name);

  @Modifying(clearAutomatically = true)
  @Query("update User set username = :username, email = :email where id = :id")
  void updateUserInfo(@Param("username") String username, @Param("email") String email, @Param("id") String id);
}
